<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<%@ page import="com.msmall.base.util.ConstantDB" language="java"%>
<c:set var="QUESTION_TERMINAL_NO" value="<%=ConstantDB.QUESTION_TERMINAL_NO%>"></c:set>
<c:set var="QUESTION_TERMINAL_YES" value="<%=ConstantDB.QUESTION_TERMINAL_YES%>"></c:set>

<div class="que_module martop10">
	<div class="w740 fl" id="question_list_nav">
		<div class="qlisttitle">
			<p class="fl qlisttitlep" id="questionListFirstTabs">
				<span class="sHB9f1"><c:out value="${cascadeSegment.current.title}"></c:out></span>
				<br/>
				<c:forEach var="currentSeg" items="${cascadeSegment.children}" varStatus="segStatus">
					<c:choose>
						<c:when test="${currentSeg.current.segmentid == segid}">
							<a onclick="javascript:questionListSegmentNav(${currentSeg.current.segmentid});" id="question_list_nav_a_${currentSeg.current.segmentid}" class="sHB9f1">
						</c:when>
						<c:otherwise>
							<a onclick="javascript:questionListSegmentNav(${currentSeg.current.segmentid});"id="question_list_nav_a_${currentSeg.current.segmentid}" class="">
						</c:otherwise>
					</c:choose>
					<c:out value="${currentSeg.current.title}"/>
					</a>
				</c:forEach>
			</p>
			<p class="fr">
				<a class="qlistbut" href="<c:url value='/question/ask.do'/>">妈妈要提问</a>
			</p>
			<p class="clear"></p>
		</div>
		<div class="qlistques martop10" id="question_list_content" segment="${segid}" terminal="">
			<div class="qlistquesnav" id="questionListTabs">
				<p class="" id="questionListTabs_terminal_"><a href="javascript:setQuestionListTerminal();ajaxQuestionListTabs();">全部问题</a></p>
				<p class="" id="questionListTabs_terminal_${QUESTION_TERMINAL_NO}"><a href="javascript:setQuestionListTerminal(${QUESTION_TERMINAL_NO});ajaxQuestionListTabs();">待解决</a></p>
				<p class="" id="questionListTabs_terminal_${QUESTION_TERMINAL_YES}"><a href="javascript:setQuestionListTerminal(${QUESTION_TERMINAL_YES});ajaxQuestionListTabs();">已解决</a></p>
			</div>
			<div id="questionListTabsContent"  class="qlistquesdiv"></div>
		</div>
	</div>
	
	<div class="w250 fr">
		<tiles:insertDefinition name="html.question.index.mother"></tiles:insertDefinition>
		<tiles:insertDefinition name="html.question.index.baby"></tiles:insertDefinition>
		<tiles:insertDefinition name="html.question.index.growcycle"></tiles:insertDefinition>
	</div>
</div>

<script>
function questionListSegmentNav(segmentid){
	var spanid = "#question_list_nav_a_"+segmentid;
	$("#question_list_content").attr('segment', segmentid);
	$("#questionListFirstTabs a").each(function(index, ele){
		if($(this).attr('id') == ('question_list_nav_a_'+segmentid)){
			$(this).addClass('qlistquesnavbg');
			$(this).removeClass('');
		}else{
			$(this).addClass('');
			$(this).removeClass('qlistquesnavbg');
		}
	});
	setQuestionListTerminal();
	ajaxQuestionListTabs();
}
function setQuestionListTerminal(terminal){
	if(terminal){
		$("#question_list_content").attr('terminal', terminal);
	}else{
		$("#question_list_content").attr('terminal', '');
	}
}
function ajaxQuestionListTabs(pageIndex){
	var dataInfo = 'segid='+$("#question_list_content").attr('segment');
	var terminal = $("#question_list_content").attr('terminal');
	if(terminal){
		dataInfo = dataInfo + '&terminal='+terminal;
	}
	if(pageIndex){
		dataInfo = dataInfo + '&pi='+pageIndex;
	}
	$.ajax({
		type : "POST",
		url : '<c:url value="/question/fetch.do"/>',
		data : dataInfo,
		timeout:20000,
		success : function(data){
			$('#questionListTabsContent').html(data);
		},
		error: function(){
		}
	});

	$("#questionListTabs p").each(function(index, ele){
		var showID = 'questionListTabs_terminal_';
		if(terminal){
			showID = showID + terminal;
		}
		if($(this).attr('id') == showID){
			$(this).addClass('qlistquesnavbg');
			$(this).removeClass('');
		}else{
			$(this).addClass('');
			$(this).removeClass('qlistquesnavbg');
		}
	});
}
ajaxQuestionListTabs();
</script>
